/*
 * @Description: 
 * @Author: Zhang Zhangda
 * @Date: 2021-02-25 17:37:18
 * @LastEditTime: 2021-02-28 16:31:42
 * @LastEditors: Zhang Zhaoda
 */
//引入类型
import {GETCOLORDATA,CHANGECOLORKEY} from "../types/color.types"

export interface KeyInter{
  [key: string]: any
}
export interface Istate{
  colorData:KeyInter,
  colorKey:string,
}
let defaultData={
    colorData:{},//车型页面数据,
    colorKey:''
}
let reducer=(state:Istate=defaultData,action:any)=>{
  switch (action.type) {
    case GETCOLORDATA:{
      let list=action.list
      
      return {...state,colorData:list,colorKey:Object.keys(action.list)[0]}
    }
    case CHANGECOLORKEY:{
      
      return {...state,colorKey:action.colorKey}
    }
      
  
    default:
     return state
  }
}


export default reducer